package com.example.jimanguang.Entity;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.dialect.TypeNames;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Entity
@Table(name = "comics")
@Getter
@Setter
public class Comics extends  BaseEntity{

    private String comicName;//漫画名称

    private String comicAuthor;//作者

    private String comicDetails;//漫画详情

    private String comicCover;//漫画封面

    private int charperCount;//章节数量

    private int readingCount;//阅读次数

    private Boolean isOpen;//是否通过申请


    @Temporal(TemporalType.TIMESTAMP)//确保实体类中的属性类型与数据库中的时间属性类型相匹配
    private Date createTime;//漫画发布的时间
    @Temporal(TemporalType.TIMESTAMP)//确保实体类中的属性类型与数据库中的时间属性类型相匹配
    private Date updateTime;//漫画更新的时间

    public Comics() {
        this.createTime = new Date();
        this.updateTime = createTime;
    }

    @OneToMany(mappedBy = "comics")
    private List<Comments> comments=new ArrayList<>();
    @OneToOne
    private ReadingHIstory readingHIstory;
    @OneToOne
    private RewardComic rewardComic;
    @OneToOne
    private SubsribeComic subsribeComics;
    @OneToOne
    private Collect collect;
    @ManyToMany(mappedBy = "comics")
    private List<ComicType>  comicTypes=new ArrayList<>();

    @OneToMany(mappedBy = "comics")
    private List<Chapters> chapters=new ArrayList<>();

    @OneToOne
    private Appliction appliction;

    @JsonManagedReference
    public List<Comments> getComments(){return comments;}

    @JsonIgnore
    public List<ComicType>  getComicTypes(){return comicTypes;}

    @JsonManagedReference
    public List<Chapters> getChapters(){return chapters;}


}
